{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Imports and data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-09-19T20:57:11.026770Z",
     "start_time": "2020-09-19T20:57:08.303893Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import modin.pandas as md\n",
    "import swifter"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "These data (~71 million rows) were taken from https://www.kaggle.com/benhamner/sf-bay-area-bike-share/data "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-09-19T20:42:35.334991Z",
     "start_time": "2020-09-19T20:42:34.402637Z"
    }
   },
   "outputs": [],
   "source": [
    "trips = pd.read_csv('../data/trip.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-09-19T20:58:23.121034Z",
     "start_time": "2020-09-19T20:57:25.006560Z"
    }
   },
   "outputs": [],
   "source": [
    "data = pd.read_csv(\"../data/status.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-09-19T20:58:23.194239Z",
     "start_time": "2020-09-19T20:58:23.131557Z"
    }
   },
   "outputs": [],
   "source": [
    "print(data.shape)\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Apply any function in the fastest available manner"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## When possible, vectorized form of function is used for 100x speed of pandas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "def bikes_proportion(x, max_x):\n",
    "    return x * 1.0 / max_x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "max_x = np.max(data['bikes_available'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 952 ms, sys: 952 ms, total: 1.9 s\n",
      "Wall time: 1.9 s\n"
     ]
    }
   ],
   "source": [
    "%time data['bike_prop'] = data['bikes_available'].swifter.apply(bikes_proportion, max_x=max_x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## When vectorized form is not available, utilized dask parallel processing for 10x speed of pandas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "def gt_5_bikes(x):\n",
    "    if x > 5:\n",
    "        return True\n",
    "    else:\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "6b5a93975c0943cd9919db10fee34fe8",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(IntProgress(value=0, description='Dask Apply', max=48), HTML(value='')))"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "CPU times: user 2.55 s, sys: 2.54 s, total: 5.1 s\n",
      "Wall time: 8.62 s\n"
     ]
    }
   ],
   "source": [
    "%time data['gt_5_bikes'] = data['bikes_available'].swifter.apply(gt_5_bikes)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### But when possible, you should still write code in a vectorized format"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "def gt_5_bikes_vectorized(x):\n",
    "    return np.where(x > 5, True, False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 138 ms, sys: 29.7 ms, total: 168 ms\n",
      "Wall time: 167 ms\n"
     ]
    }
   ],
   "source": [
    "%time data['gt_5_bikes_vec'] = data['bikes_available'].swifter.apply(gt_5_bikes_vectorized)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>station_id</th>\n",
       "      <th>bikes_available</th>\n",
       "      <th>docks_available</th>\n",
       "      <th>time</th>\n",
       "      <th>bike_prop</th>\n",
       "      <th>gt_5_bikes</th>\n",
       "      <th>gt_5_bikes_vec</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:06:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:07:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:08:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:09:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:10:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   station_id  bikes_available  docks_available                 time  \\\n",
       "0           2                2               25  2013/08/29 12:06:01   \n",
       "1           2                2               25  2013/08/29 12:07:01   \n",
       "2           2                2               25  2013/08/29 12:08:01   \n",
       "3           2                2               25  2013/08/29 12:09:01   \n",
       "4           2                2               25  2013/08/29 12:10:01   \n",
       "\n",
       "   bike_prop  gt_5_bikes  gt_5_bikes_vec  \n",
       "0   0.074074       False           False  \n",
       "1   0.074074       False           False  \n",
       "2   0.074074       False           False  \n",
       "3   0.074074       False           False  \n",
       "4   0.074074       False           False  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## When you can't write code in a vectorized format, swifter still makes parallel processing easy "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-09-19T20:44:07.040669Z",
     "start_time": "2020-09-19T20:43:55.704540Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 10.5 s, sys: 751 ms, total: 11.3 s\n",
      "Wall time: 11.3 s\n"
     ]
    }
   ],
   "source": [
    "%time data['date'] = data['time'].swifter.apply(pd.to_datetime)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "def convert_to_human(datetime):\n",
    "    return datetime.day_name() + ', the ' + str(datetime.day) + 'th day of ' + datetime.strftime(\"%B\") + ', ' + str(datetime.year)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "e0faa693c0e241fdb0647344dae16e4f",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(IntProgress(value=0, description='Dask Apply', max=48), HTML(value='')))"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "CPU times: user 4min 18s, sys: 2min 2s, total: 6min 21s\n",
      "Wall time: 30min 25s\n"
     ]
    }
   ],
   "source": [
    "%time data['readable_date'] = data['date'].swifter.apply(convert_to_human)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>station_id</th>\n",
       "      <th>bikes_available</th>\n",
       "      <th>docks_available</th>\n",
       "      <th>time</th>\n",
       "      <th>bike_prop</th>\n",
       "      <th>gt_5_bikes</th>\n",
       "      <th>gt_5_bikes_vec</th>\n",
       "      <th>date</th>\n",
       "      <th>readable_date</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:06:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:06:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:07:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:07:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:08:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:08:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:09:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:09:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:10:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:10:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   station_id  bikes_available  docks_available                 time  \\\n",
       "0           2                2               25  2013/08/29 12:06:01   \n",
       "1           2                2               25  2013/08/29 12:07:01   \n",
       "2           2                2               25  2013/08/29 12:08:01   \n",
       "3           2                2               25  2013/08/29 12:09:01   \n",
       "4           2                2               25  2013/08/29 12:10:01   \n",
       "\n",
       "   bike_prop  gt_5_bikes  gt_5_bikes_vec                date  \\\n",
       "0   0.074074       False           False 2013-08-29 12:06:01   \n",
       "1   0.074074       False           False 2013-08-29 12:07:01   \n",
       "2   0.074074       False           False 2013-08-29 12:08:01   \n",
       "3   0.074074       False           False 2013-08-29 12:09:01   \n",
       "4   0.074074       False           False 2013-08-29 12:10:01   \n",
       "\n",
       "                            readable_date  \n",
       "0  Thursday, the 29th day of August, 2013  \n",
       "1  Thursday, the 29th day of August, 2013  \n",
       "2  Thursday, the 29th day of August, 2013  \n",
       "3  Thursday, the 29th day of August, 2013  \n",
       "4  Thursday, the 29th day of August, 2013  "
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Multiple columns apply example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "def bikes_per_dock_availability_ratio(bikes_avail, docks_avail):\n",
    "    return bikes_avail / docks_avail"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 2.97 s, sys: 6.86 s, total: 9.83 s\n",
      "Wall time: 11.7 s\n"
     ]
    }
   ],
   "source": [
    "%time data[\"bikes_available_per_dock_available\"] = data[['bikes_available', 'docks_available']].swifter.apply(lambda row: bikes_per_dock_availability_ratio(row[\"bikes_available\"], row[\"docks_available\"]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>station_id</th>\n",
       "      <th>bikes_available</th>\n",
       "      <th>docks_available</th>\n",
       "      <th>time</th>\n",
       "      <th>bike_prop</th>\n",
       "      <th>gt_5_bikes</th>\n",
       "      <th>gt_5_bikes_vec</th>\n",
       "      <th>date</th>\n",
       "      <th>readable_date</th>\n",
       "      <th>bikes_available_per_dock_available</th>\n",
       "      <th>rolling_sum_bikes_available</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:06:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:06:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "      <td>0.08</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:07:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:07:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "      <td>0.08</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:08:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:08:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "      <td>0.08</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:09:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:09:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "      <td>0.08</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:10:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:10:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "      <td>0.08</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   station_id  bikes_available  docks_available                 time  \\\n",
       "0           2                2               25  2013/08/29 12:06:01   \n",
       "1           2                2               25  2013/08/29 12:07:01   \n",
       "2           2                2               25  2013/08/29 12:08:01   \n",
       "3           2                2               25  2013/08/29 12:09:01   \n",
       "4           2                2               25  2013/08/29 12:10:01   \n",
       "\n",
       "   bike_prop  gt_5_bikes  gt_5_bikes_vec                date  \\\n",
       "0   0.074074       False           False 2013-08-29 12:06:01   \n",
       "1   0.074074       False           False 2013-08-29 12:07:01   \n",
       "2   0.074074       False           False 2013-08-29 12:08:01   \n",
       "3   0.074074       False           False 2013-08-29 12:09:01   \n",
       "4   0.074074       False           False 2013-08-29 12:10:01   \n",
       "\n",
       "                            readable_date  bikes_available_per_dock_available  \\\n",
       "0  Thursday, the 29th day of August, 2013                                0.08   \n",
       "1  Thursday, the 29th day of August, 2013                                0.08   \n",
       "2  Thursday, the 29th day of August, 2013                                0.08   \n",
       "3  Thursday, the 29th day of August, 2013                                0.08   \n",
       "4  Thursday, the 29th day of August, 2013                                0.08   \n",
       "\n",
       "   rolling_sum_bikes_available  \n",
       "0                          NaN  \n",
       "1                          NaN  \n",
       "2                          NaN  \n",
       "3                          NaN  \n",
       "4                          NaN  "
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Applymap example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "start_time": "2020-09-19T20:49:34.719Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "UserWarning: This pandas object has duplicate indices, and swifter may not be able to improve performance. Consider resetting the indices with `df.reset_index(drop=True)`.\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "d93761d460db4ff8bac6d98425b09109",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(FloatProgress(value=0.0, description='Dask Applymap', max=24.0, style=ProgressStyle(description…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "data[[\"bikes_available\", \"docks_available\"]] = data[[\"bikes_available\", \"docks_available\"]].swifter.applymap(float)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Groupby Apply Example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>duration</th>\n",
       "      <th>start_date</th>\n",
       "      <th>start_station_name</th>\n",
       "      <th>start_station_id</th>\n",
       "      <th>end_date</th>\n",
       "      <th>end_station_name</th>\n",
       "      <th>end_station_id</th>\n",
       "      <th>bike_id</th>\n",
       "      <th>subscription_type</th>\n",
       "      <th>zip_code</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>4576</td>\n",
       "      <td>63</td>\n",
       "      <td>8/29/2013 14:13</td>\n",
       "      <td>South Van Ness at Market</td>\n",
       "      <td>66</td>\n",
       "      <td>8/29/2013 14:14</td>\n",
       "      <td>South Van Ness at Market</td>\n",
       "      <td>66</td>\n",
       "      <td>520</td>\n",
       "      <td>Subscriber</td>\n",
       "      <td>94127</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4607</td>\n",
       "      <td>70</td>\n",
       "      <td>8/29/2013 14:42</td>\n",
       "      <td>San Jose City Hall</td>\n",
       "      <td>10</td>\n",
       "      <td>8/29/2013 14:43</td>\n",
       "      <td>San Jose City Hall</td>\n",
       "      <td>10</td>\n",
       "      <td>661</td>\n",
       "      <td>Subscriber</td>\n",
       "      <td>95138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4130</td>\n",
       "      <td>71</td>\n",
       "      <td>8/29/2013 10:16</td>\n",
       "      <td>Mountain View City Hall</td>\n",
       "      <td>27</td>\n",
       "      <td>8/29/2013 10:17</td>\n",
       "      <td>Mountain View City Hall</td>\n",
       "      <td>27</td>\n",
       "      <td>48</td>\n",
       "      <td>Subscriber</td>\n",
       "      <td>97214</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4251</td>\n",
       "      <td>77</td>\n",
       "      <td>8/29/2013 11:29</td>\n",
       "      <td>San Jose City Hall</td>\n",
       "      <td>10</td>\n",
       "      <td>8/29/2013 11:30</td>\n",
       "      <td>San Jose City Hall</td>\n",
       "      <td>10</td>\n",
       "      <td>26</td>\n",
       "      <td>Subscriber</td>\n",
       "      <td>95060</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4299</td>\n",
       "      <td>83</td>\n",
       "      <td>8/29/2013 12:02</td>\n",
       "      <td>South Van Ness at Market</td>\n",
       "      <td>66</td>\n",
       "      <td>8/29/2013 12:04</td>\n",
       "      <td>Market at 10th</td>\n",
       "      <td>67</td>\n",
       "      <td>319</td>\n",
       "      <td>Subscriber</td>\n",
       "      <td>94103</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     id  duration       start_date        start_station_name  \\\n",
       "0  4576        63  8/29/2013 14:13  South Van Ness at Market   \n",
       "1  4607        70  8/29/2013 14:42        San Jose City Hall   \n",
       "2  4130        71  8/29/2013 10:16   Mountain View City Hall   \n",
       "3  4251        77  8/29/2013 11:29        San Jose City Hall   \n",
       "4  4299        83  8/29/2013 12:02  South Van Ness at Market   \n",
       "\n",
       "   start_station_id         end_date          end_station_name  \\\n",
       "0                66  8/29/2013 14:14  South Van Ness at Market   \n",
       "1                10  8/29/2013 14:43        San Jose City Hall   \n",
       "2                27  8/29/2013 10:17   Mountain View City Hall   \n",
       "3                10  8/29/2013 11:30        San Jose City Hall   \n",
       "4                66  8/29/2013 12:04            Market at 10th   \n",
       "\n",
       "   end_station_id  bike_id subscription_type zip_code  \n",
       "0              66      520        Subscriber    94127  \n",
       "1              10      661        Subscriber    95138  \n",
       "2              27       48        Subscriber    97214  \n",
       "3              10       26        Subscriber    95060  \n",
       "4              67      319        Subscriber    94103  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trips.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2022-07-24 03:42:43,651\tWARNING services.py:2002 -- WARNING: The object store is using /tmp instead of /dev/shm because /dev/shm has only 67104768 bytes available. This will harm performance! You may be able to free up space by deleting files in /dev/shm. If you are inside a Docker container, you can increase /dev/shm size by passing '--shm-size=3.10gb' to 'docker run' (or add it to the run_options list in a Ray cluster config). Make sure to set this to more than 30% of available RAM.\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "4057ccaffae448cca57f9e80f70678fb",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/24 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "bike_id  start_station_id\n",
       "9        2                      585.525000\n",
       "         3                   121511.800000\n",
       "         4                      301.555556\n",
       "         5                      201.000000\n",
       "         6                      976.777778\n",
       "                                 ...      \n",
       "878      74                     929.016667\n",
       "         75                    1215.828571\n",
       "         76                    1419.232143\n",
       "         77                     900.767442\n",
       "         82                     526.151515\n",
       "Length: 23213, dtype: float64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trips[[\"bike_id\",\"start_station_id\", \"duration\"]].swifter.groupby([\"bike_id\", \"start_station_id\"]).apply(lambda x: x[\"duration\"].mean())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Rolling objects apply example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-09-19T20:48:57.101623Z",
     "start_time": "2020-09-19T20:47:29.723Z"
    }
   },
   "outputs": [],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/anaconda3/lib/python3.6/site-packages/swifter/swifter.py:206: FutureWarning: Currently, 'apply' passes the values as ndarrays to the applied function. In the future, this will change to passing it as Series objects. You need to specify 'raw=True' to keep the current behaviour, and you can pass 'raw=False' to silence this warning\n",
      "  self._samp_pd.apply(func, *args, **kwds)\n",
      "/anaconda3/lib/python3.6/site-packages/dask/dataframe/rolling.py:179: FutureWarning: Currently, 'apply' passes the values as ndarrays to the applied function. In the future, this will change to passing it as Series objects. You need to specify 'raw=True' to keep the current behaviour, and you can pass 'raw=False' to silence this warning\n",
      "  return getattr(rolling, name)(*args, **kwargs)\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "437313dc6ba94d76b3e50ab46af5c05f",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(IntProgress(value=0, description='Dask Apply', max=47), HTML(value='')))"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "CPU times: user 5.01 s, sys: 11.5 s, total: 16.5 s\n",
      "Wall time: 34.8 s\n"
     ]
    }
   ],
   "source": [
    "%time data[\"rolling_sum_bikes_available\"] = data['bikes_available'].swifter.rolling(10).apply(sum)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>station_id</th>\n",
       "      <th>bikes_available</th>\n",
       "      <th>docks_available</th>\n",
       "      <th>time</th>\n",
       "      <th>bike_prop</th>\n",
       "      <th>gt_5_bikes</th>\n",
       "      <th>gt_5_bikes_vec</th>\n",
       "      <th>date</th>\n",
       "      <th>readable_date</th>\n",
       "      <th>bikes_available_per_dock_available</th>\n",
       "      <th>rolling_sum_bikes_available</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:18:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:18:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "      <td>0.08</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:19:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:19:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "      <td>0.08</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:20:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:20:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "      <td>0.08</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:21:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:21:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "      <td>0.08</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:22:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:22:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "      <td>0.08</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:23:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:23:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "      <td>0.08</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:25:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:25:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "      <td>0.08</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:26:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:26:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "      <td>0.08</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:27:04</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:27:04</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "      <td>0.08</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:29:01</td>\n",
       "      <td>0.074074</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>2013-08-29 12:29:01</td>\n",
       "      <td>Thursday, the 29th day of August, 2013</td>\n",
       "      <td>0.08</td>\n",
       "      <td>20.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    station_id  bikes_available  docks_available                 time  \\\n",
       "10           2                2               25  2013/08/29 12:18:01   \n",
       "11           2                2               25  2013/08/29 12:19:01   \n",
       "12           2                2               25  2013/08/29 12:20:01   \n",
       "13           2                2               25  2013/08/29 12:21:01   \n",
       "14           2                2               25  2013/08/29 12:22:01   \n",
       "15           2                2               25  2013/08/29 12:23:01   \n",
       "16           2                2               25  2013/08/29 12:25:01   \n",
       "17           2                2               25  2013/08/29 12:26:01   \n",
       "18           2                2               25  2013/08/29 12:27:04   \n",
       "19           2                2               25  2013/08/29 12:29:01   \n",
       "\n",
       "    bike_prop  gt_5_bikes  gt_5_bikes_vec                date  \\\n",
       "10   0.074074       False           False 2013-08-29 12:18:01   \n",
       "11   0.074074       False           False 2013-08-29 12:19:01   \n",
       "12   0.074074       False           False 2013-08-29 12:20:01   \n",
       "13   0.074074       False           False 2013-08-29 12:21:01   \n",
       "14   0.074074       False           False 2013-08-29 12:22:01   \n",
       "15   0.074074       False           False 2013-08-29 12:23:01   \n",
       "16   0.074074       False           False 2013-08-29 12:25:01   \n",
       "17   0.074074       False           False 2013-08-29 12:26:01   \n",
       "18   0.074074       False           False 2013-08-29 12:27:04   \n",
       "19   0.074074       False           False 2013-08-29 12:29:01   \n",
       "\n",
       "                             readable_date  \\\n",
       "10  Thursday, the 29th day of August, 2013   \n",
       "11  Thursday, the 29th day of August, 2013   \n",
       "12  Thursday, the 29th day of August, 2013   \n",
       "13  Thursday, the 29th day of August, 2013   \n",
       "14  Thursday, the 29th day of August, 2013   \n",
       "15  Thursday, the 29th day of August, 2013   \n",
       "16  Thursday, the 29th day of August, 2013   \n",
       "17  Thursday, the 29th day of August, 2013   \n",
       "18  Thursday, the 29th day of August, 2013   \n",
       "19  Thursday, the 29th day of August, 2013   \n",
       "\n",
       "    bikes_available_per_dock_available  rolling_sum_bikes_available  \n",
       "10                                0.08                         20.0  \n",
       "11                                0.08                         20.0  \n",
       "12                                0.08                         20.0  \n",
       "13                                0.08                         20.0  \n",
       "14                                0.08                         20.0  \n",
       "15                                0.08                         20.0  \n",
       "16                                0.08                         20.0  \n",
       "17                                0.08                         20.0  \n",
       "18                                0.08                         20.0  \n",
       "19                                0.08                         20.0  "
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.iloc[10:20,:]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Resampler apply example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data.set_index(\"date\", inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-09-19T20:46:50.270878Z",
     "start_time": "2020-09-19T20:45:50.573305Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "UserWarning: This pandas object has duplicate indices, and swifter may not be able to improve performance. Consider resetting the indices with `df.reset_index(drop=True)`.\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "3e14e7e4d776445b957dc491422ffd18",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(FloatProgress(value=0.0, description='Dask Apply', max=95.0, style=ProgressStyle(description_wi…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "%time data[\"daily_avg_bikes_available\"] = data[\"bikes_available\"].swifter.resample(\"1d\").apply(np.mean)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Modin apply example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-09-19T20:59:38.483833Z",
     "start_time": "2020-09-19T20:58:23.198149Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "UserWarning: Distributing <class 'pandas.core.frame.DataFrame'> object. This may take some time.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 101 ms, sys: 68.4 ms, total: 170 ms\n",
      "Wall time: 1.61 s\n"
     ]
    }
   ],
   "source": [
    "modin_data = md.DataFrame(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-09-19T21:00:16.575345Z",
     "start_time": "2020-09-19T21:00:15.033535Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 79.9 ms, sys: 30.7 ms, total: 111 ms\n",
      "Wall time: 1.53 s\n"
     ]
    }
   ],
   "source": [
    "%time modin_data[\"bikes_available_plus1\"] = modin_data[\"bikes_available\"].swifter.apply(lambda x: x+1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-09-19T21:00:33.350264Z",
     "start_time": "2020-09-19T21:00:16.580682Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>station_id</th>\n",
       "      <th>bikes_available</th>\n",
       "      <th>docks_available</th>\n",
       "      <th>time</th>\n",
       "      <th>bikes_available_plus1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:06:01</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:07:01</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:08:01</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:09:01</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>25</td>\n",
       "      <td>2013/08/29 12:10:01</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   station_id  bikes_available  docks_available                 time  \\\n",
       "0           2                2               25  2013/08/29 12:06:01   \n",
       "1           2                2               25  2013/08/29 12:07:01   \n",
       "2           2                2               25  2013/08/29 12:08:01   \n",
       "3           2                2               25  2013/08/29 12:09:01   \n",
       "4           2                2               25  2013/08/29 12:10:01   \n",
       "\n",
       "   bikes_available_plus1  \n",
       "0                      3  \n",
       "1                      3  \n",
       "2                      3  \n",
       "3                      3  \n",
       "4                      3  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "modin_data.head()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
